import { createApp } from 'vue'
import App from './App.vue'
import router, { setupRouter } from '@/router/index'
import { setupStore } from '@/store/index'
import { initAegis } from '@/utils/aegis'

// 开发环境下导入测试功能
if (import.meta.env.DEV) import('@/utils/aegis-test')
  
  // element-plus相关
  import 'element-plus/dist/index.css'
  import 'element-plus/theme-chalk/dark/css-vars.css'
  import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  import './styles/index.scss'
  import './styles/lightboxTheme/index.scss'

// 国际化
import { setupI18n } from '@/locales/index'

// 挂载全局方法
async function bootstrap(): Promise<void> {
  const app = createApp(App)
  
  // 挂载国际化 - 确保在应用挂载前完成
  setupI18n(app)

  // 初始化 Aegis 监控
  initAegis()

  setupStore(app)

  setupRouter(app)
  await router.isReady()

  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
  

  app.mount('#app', true)
}

void bootstrap()
